package com.imoblife.brainwavestus.listener;

import java.util.ArrayList;

import com.imoblife.brainwavestus.GroupCommonProductActivity;
import com.imoblife.brainwavestus.model.Constant;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;

public class OnCategoryItemClickListener implements OnItemClickListener {
	
	private ArrayList<String> mData;
	private Context mCtx;
	private int mSource;
	
	public OnCategoryItemClickListener(Context ctx
					,ArrayList<String> data
					,int source) {
		
		mCtx = ctx;
		mData = data;
		mSource = source;
	}
	
	@Override
	public void onItemClick(AdapterView<?> parent, View view, int position,
			long id) {
		
		String category = mData.get(position);
		
		Intent intent = new Intent(mCtx,
					GroupCommonProductActivity.class);
		
		intent.setAction(Constant.ACTION_CATEGORY_SHOW);
		intent.putExtra(Constant.SOURCE, mSource);
		intent.putExtra(Constant.CATEGORY_NAME, category);
		
		mCtx.startActivity(intent);
	}

}
